package es.cea.filters;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * Servlet Filter implementation class FiltroHTML
 */
public class FiltroHTML implements Filter {

    /**
     * Default constructor. 
     */
    public FiltroHTML() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see Filter#destroy()
	 */
	public void destroy() {
		// TODO Auto-generated method stub
	}

	/**
	 * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
	 */
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		System.out.println("antes del filtro");
		PrintWriter writer = response.getWriter();
		writer.print("<html>" +
				"<head><title>HELLO FILTER</title></head>" +
				"<body style='background:red;'>");
		chain.doFilter(request, response);
		System.out.println("despues del filtro"+url);
		writer.print("</body></html>");
		
	}
	String url ;
	public void init(FilterConfig fConfig) throws ServletException {
		 url = fConfig.getInitParameter("url");
	}

}
